package com.itheima.springboot.conditional;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

import java.util.Map;

public class Condutional_Class  implements Condition {

    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {

        Map<String, Object> annotationAttributes = annotatedTypeMetadata.getAnnotationAttributes(ConditionOnClass.class.getName());
        String[] value = (String[]) annotationAttributes.get("value");

        boolean flag = true;
        try {
            //
            for (String name : value) {
                Class<?> aClass = Class.forName(name);
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            return false;
        }
        return flag;
    }
}
